import tensorflow as tf

def noisy_activation(x):

    h = tf.nn.relu(0.5 * x + 0.5) - tf.nn.relu(0.5 * x - 0.5) - 0.5
    y = h + tf.square(tf.sigmoid(h - x) - 0.5) * tf.random.normal(tf.shape(x),
                                                                  mean=0.0,
                                                                  stddev=1.0,
                                                                  dtype=tf.float32
                                                                  )
    return y
